package com.edu.controller.foodtype;

import com.edu.entity.FoodType;
import com.edu.service.foodtype.FoodTypeService;
import com.edu.service.foodtype.FoodTypeServiceImpl;
import com.edu.utils.ParamFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author ZCN
 * @version 1.0
 * @date 2021/11/19 14:27
 */
@WebServlet("/foodtype/findall")
public class SelectAllServlet extends HttpServlet {
    private FoodTypeService foodTypeService = new FoodTypeServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            ParamFormat.format(req, resp);
            List<FoodType> foodTypeList = foodTypeService.findAll();
            req.setAttribute("foodtypelist",foodTypeList);
            req.getRequestDispatcher("/system/foodtype.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
